<div
    bsModal
    #createOrEditModal="bs-modal"
    class="modal fade"
    tabindex="-1"
    role="dialog"
    aria-labelledby="createOrEditModal"
    aria-hidden="true"
    [config]="{ backdrop: 'static' }"
    (onHidden)="onHidden($event)"
>
    <div class="modal-dialog modal-xxl">
        <div class="modal-content">
            <form *ngIf="active" #editForm="ngForm" novalidate (ngSubmit)="save()" autocomplete="off">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>{{ billbase.f_ReceiveDept }}盘点单</span>
                    </h4>
                    <button type="button" class="close" (click)="cancel()" [attr.aria-label]="l('Close')">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>

                <div class="modal-body">
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <div class="row align-items-center">
                            <div class="col-md-6">
                                <h4 class="m-subheader__title">盘点单详细信息</h4>
                            </div>
                            <div class="col-md-6 m--align-right">
                                <div class="btn-group m-btn-group" role="group" aria-label="...">
                                    <button
                                        type="button"
                                        class="btn btn-default m--padding-left-5 m--padding-right-5"
                                        (click)="accountmodalshow()"
                                    >
                                        新增
                                    </button>
                                    <button
                                        [disabled]="!selectedBill"
                                        type="button"
                                        class="btn btn-default m--padding-left-5 m--padding-right-5"
                                        (click)="delete()"
                                    >
                                        删除
                                    </button>
                                </div>
                            </div>
                            <div class="col-md-12 m--margin-top-20">
                                <p-table
                                    #detailDataTable
                                    [value]="miliInventoryBillList"
                                    [paginator]="false"
                                    [lazy]="true"
                                    [scrollable]="true"
                                    ScrollWidth="100%"
                                    [responsive]="primengTableHelper.isResponsive"
                                    [resizableColumns]="primengTableHelper.resizableColumns"
                                    selectionMode="single"
                                    [(selection)]="selectedBill"
                                >
                                    <ng-template pTemplate="header">
                                        <tr>
                                            <th style="width: 40px">
                                                序号
                                            </th>
                                            <th width="120px">
                                                材料编号
                                            </th>
                                            <th width="120px">
                                                材料名称
                                            </th>
                                            <th width="80px">
                                                实际库存
                                            </th>
                                            <th width="80px">
                                                盘点数量
                                            </th>
                                            <th width="180px">
                                                盘点原因
                                            </th>
                                            <th width="120px">
                                                仓库
                                            </th>
                                            <th width="120px">
                                                批处理号
                                            </th>

                                            <th width="100px">
                                                计量单位
                                            </th>

                                            <th width="100px">
                                                单价
                                            </th>
                                        </tr>
                                    </ng-template>

                                    <ng-template pTemplate="body" let-record="$implicit" let-i="rowIndex">
                                        <tr [pSelectableRow]="record">
                                            <td style="width: 40px">
                                                {{ i + 1 }}
                                            </td>

                                            <td width="120px">
                                                {{ record.f_MaterialCode }}
                                            </td>
                                            <td width="120px">
                                                {{ record.f_MaterialName }}
                                            </td>
                                            <td width="80px">
                                                {{ record.f_Quantity | number: '1.3-3'}}
                                            </td>
                                            <td style=" padding: 0 !important;  margin: 0 !important;" width="80px">
                                                <input
                                                    type="number"
                                                    [(ngModel)]="record.inventoryQTY"
                                                    style="width: 100%;"
                                                    name="'InventoryQTY_'+i"
                                                />
                                            </td>
                                            <td style=" padding: 0 !important;  margin: 0 !important;" width="180px">
                                                <input
                                                    type="text"
                                                    [(ngModel)]="record.reason"
                                                    style="width: 100%;"
                                                    name="'reason_'+i"
                                                />
                                            </td>
                                            <td width="120px">
                                                {{ record.f_WarehouseCode }}
                                            </td>
                                            <td width="120px">
                                                {{ record.f_InventBatchID }}
                                            </td>

                                            <td width="100px">
                                                {{ record.f_Unit }}
                                            </td>

                                            <td width="100px">
                                                {{ record.f_UnitPrice }}
                                            </td>
                                        </tr>
                                    </ng-template>
                                </p-table>
                            </div>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button [disabled]="saving" type="button" class="btn btn-default" (click)="cancel()">
                            {{ l('Cancel') }}
                        </button>
                        <button
                            type="submit"
                            class="btn btn-primary blue"
                            [disabled]="!editForm.form.valid"
                            [buttonBusy]="saving"
                            [busyText]="l('SavingWithThreeDot')"
                        >
                            <i class="fa fa-save"></i>
                            <span>{{ l('Save') }}</span>
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
